<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>

<body>
    <input type="button" value="点击" id="btn">


    <script>
        var btn = document.getElementById("btn");
        btn.onclick = function () {
            alert("你好");
        }
    </script>

    <!-- <input type="button" value="点击" onclick="test()"> -->
    <!-- <script>
        /* 
            js代码在页面的编写位置：
            1、head标签中
            2、body标签中的最后方
        */
        function test() {
            alert("hello");
        }
    </script> -->
</body>
</html>